import { configureStore } from "@reduxjs/toolkit";
import tofoReducer from "./todoList";
import userReducer, { userinfoType } from "./userInfo";
import { itemType } from "./todoList";
import componentReducer, { ComponentStatetype } from "./componentReducer";
//设置页面信息的redux
import pageInfoReducer, { pageInfoStateType } from "./pageInfoReducer";
//引入撤销操作
import undoable, { excludeAction, StateWithHistory } from "redux-undo";

export type StateType = {
  tofoReducer: itemType[];
  userReducer: userinfoType;
  componentReducer: StateWithHistory<ComponentStatetype>;
  pageInfoReducer: pageInfoStateType;
};
const store = configureStore({
  reducer: {
    tofoReducer,
    userReducer,
    componentReducer: undoable(componentReducer, {
      limit: 20,
      filter: excludeAction([
        "componentReducer/resetComponent",
        "componentReducer/selectPrevComponent",
        "componentReducer/selectNextComponent",
        "componentReducer/copyComponentFun",
        "componentReducer/pasteComponent",
      ]),
    }),
    pageInfoReducer,
  },
});

export default store;
